<template>
    <van-nav-bar title="商品分类"  left-arrow @click-left="()=>{$router.push('/')}" />
    <div v-if="Gujia">
        <van-skeleton title :row="33" />
    </div>
    <div v-else>
        <van-row>
            <van-col span="6">
                <van-sidebar v-model="active">
                    <van-sidebar-item v-for="item in claData" :title="item.cat_name" />
                </van-sidebar> </van-col>
            <van-col span="18">
                <div v-for="item in claData[active]?.children">
                    <h4>{{ item.cat_name }}</h4>
                    <van-grid :column-num="3">
                        <van-grid-item v-for="items in item.children" :icon="items.cat_icon" :text="items.cat_name" />
                    </van-grid>
                </div>
            </van-col>
        </van-row>
    </div>
</template>

<script setup>

import { ref } from 'vue';
import { categoriesApi } from '@/api/api';
const active = ref(1);
const claData = ref([])
categoriesApi().then(res => {
    console.log('分类数据', res);
    claData.value = res.data.message
})
const Gujia = ref(true)
setInterval(() => {
    Gujia.value = false

}, 1000)
</script>

<style lang="scss" scoped></style>